﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class signup2 : System.Web.UI.Page
{
    DatabaseProcess dbClass = new DatabaseProcess();
    DataTable dt = new DataTable();    

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["username"] != null) {
            signuppage.Visible = false;
            notify.Text = "you are trying sign up while still logged in!! sign out first, please!";
        }
    }

    protected void ButtonMakeProfile_Click(object sender, EventArgs e)
    {
        string chkUser = "Select * FROM [User_] where Email='" + TextBoxEmail.Text + "'";
        dt = dbClass.ConnectDataBaseReturnDT(chkUser);
        if (dt.Rows.Count > 0)
        {
            check_mail.Text = "Duplicate Email!!! choose another email address, please";
        }
        else
        {
            string RegisterQuery = "INSERT INTO [User_] (Email,Password_,Name,Country,Description,role) VALUES('" + TextBoxEmail.Text + "','" + TextBoxPassword.Text + "','" + TextBoxName.Text + "','" + TextBoxCountry.Text + "','" + TextBoxComment.Text + "',1)";
            dbClass.ConnectDataBaseToInsert(RegisterQuery);
            Response.Redirect("~/Login.aspx?signup=1");
        }
    }
}